#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 5e6 + 10, p = 998244353;

LL T, n;
LL f[N]; // i的阶乘
LL g[N]; // i的阶乘的逆元

LL qpow(LL a, LL b, LL p)
{
	LL ans = 1;
	while(b)
	{
		if(b & 1) ans = ans * a % p;
		a = a * a % p;
		b >>= 1;
	}
	return ans;
}

void init()
{
	f[0] = 1;
	for(int i = 1;i <= n;i ++) f[i] = f[i - 1] * i % p;
	g[n] = qpow(f[n], p - 2, p);
	for(int i = n - 1;i >= 0;i --) g[i] = g[i + 1] * (i + 1) % p;
}

LL C(LL n, LL m)
{
	if(n < m) return 0;
	return (f[n] * g[m] % p) * g[n - m] % p;
}

int main()
{
	cin >> T >> n;
	init();
	LL ans  = 0;
	while(T --)
	{
		LL a, b; scanf("%lld%lld", &a, &b);
		ans ^= C(a, b);
	}
	cout << ans << endl;
	return 0;
}